﻿<?php

class DefaultApp extends BaseApp
{
    function index()
    {
		if($GLOBALS['SCup']->SCup_user_checking == false)
		{
		$this->login();
		exit;
		}
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));
		
        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');	
		
        $this->assign('leftframe',SITE_URL.'/admin/index.php?app=menu');
        $this->assign('mainframe',SITE_URL.'/admin/index.php?app=default&act=main');
		
        $this->display('index.view.php');
    }



    function main()
    {		
	
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));

        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');

				
        $this->display('main.view.php');
    }


    function login()
    {		
	    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
		header("Cache-Control: no-cache, must-revalidate");
		header("Pragma: no-cache");	
	    
        $this->assign('view_charset', VIEW_CHARSET);	
        $this->assign('page_title', $GLOBALS['Lang']->_get_lang_var(SITE_TITLE));
        $this->assign('page_description', $GLOBALS['Lang']->_get_lang_var(SITE_DESCRIPTION));
        $this->assign('page_keywords', $GLOBALS['Lang']->_get_lang_var(SITE_KEYWORDS));

        $this->assign('web_view_dir',SITE_URL.'/admin/view/default/');

				
        $this->display('login.view.php');
    }

 
 
    function loginpost()
    {	
		if(!isset($_POST['username']))
		{
		$_POST['username'] ='';
		}
		if(!isset($_POST['userpwd']))
		{
		$_POST['userpwd'] ='';
		}
		$username = $_POST['username'];		
		$pwd =  $_POST['userpwd'];
		
	    $user = & $GLOBALS['SCup']->_get_user(); 						
	    if($user->login($username,$pwd))
		{
		  $this->login_logs($username,'成功登录,保密了',get_ip());
          $this->index();
		
		}
		else
		{
		  $this->login_logs($username,$pwd,get_ip());
		$this->login();
		}
			    

    }

    function quit()
    {		
	
	   $user = & $GLOBALS['SCup']->_get_user();		
	   if($user->quit())
	   {
	   $GLOBALS['SCup']->SCup_user_checking = false;

	   }
	   else
	   {
	   $notice = &get_message(array('msg'=>'False!','url'=>'','title'=>'Notice'));
	   $notice ->display();	   
	   
	   }
 	   $notice = &get_message(array('msg'=>'True!','url'=>SITE_URL,'title'=>'Notice'));
	   $notice ->display();   
       
    }

   function login_logs($username,$password,$onlineip){
	$timestamp = time();
	$logdb[]="$username\t$password\t$timestamp\t$onlineip";
	@include(ROOT_PATH."/data/logs/adminlogin_logs.php");
	$writefile="<?php	\r\n";
	$jj=0;
	foreach($logdb AS $key=>$value){
		$jj++;
		$value=addslashes($value);
		$writefile.="\$logdb[]='$value';\r\n";
		if($jj>200){
			break;
		}
	}
	write_file(ROOT_PATH."/data/logs/adminlogin_logs.php",$writefile);
}


  
}
?>